home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vbdatabs / llist.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-03-17  |  2.4 KB  |  74 lines

  1. // ------------------------------- //
  2. // -------- Start of File -------- //
  3. // ------------------------------- //
  4. // ----------------------------------------------------------- //
  5. // C++ Header File Name: llist.h 
  6. // Compiler Used: MSVC40, DJGPP 2.7.2.1, GCC 2.7.2.1, HP CPP 10.24
  7. // Produced By: Doug Gaer 
  8. // File Creation Date: 04/05/1996 
  9. // Date Last Modified: 03/17/1999
  10. // ----------------------------------------------------------- // 
  11. // ---------- Include File Description and Details  ---------- // 
  12. // ----------------------------------------------------------- // 
  13. /*
  14. THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.
  15. THE ENTIRE RISK OF THE QUALITY AND PERFORMANCE OF THIS SOFTWARE
  16. IS WITH YOU. SHOULD ANY ELEMENT OF THIS SOFTWARE PROVE DEFECTIVE,
  17. YOU WILL ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR
  18. CORRECTION.
  19.  
  20. Simple doubly linked list implementation.
  21. */
  22. // ----------------------------------------------------------- //   
  23. #ifndef __LLIST_HPP
  24. #define __LLIST_HPP
  25.  
  26. // Define the data type being used
  27. typedef long listTYPE;
  28.  
  29. // Doubly linked list base class
  30. class LListB
  31. {
  32. public:
  33.   LListB() { Next =  Prior= 0; info = 0; }
  34.   
  35. public:
  36.   LListB *GetNext() { return Next; }           // Get the next link
  37.   LListB *GetPrior() { return Prior; }         // Get the previous link
  38.   listTYPE Get() { return info; }              // Get the current element
  39.   void Change(listTYPE data) { info = data; }  // Change an element
  40.  
  41. public:
  42.   listTYPE info;
  43.   LListB *Next;
  44.   LListB *Prior;
  45. };
  46.  
  47. // Doubly linked list class
  48. class LList : public LListB
  49. {
  50. public:
  51.   LList() { Start = End = 0; }
  52.   ~LList() { Clear(); }
  53.  
  54. public:
  55.   void Store(listTYPE);        // Store a node
  56.   LListB *Detach(LListB *ptr); // Detach a node from the list
  57.   void Remove(LListB *ptr);    // Detach node and remove from memory
  58.   LListB *Find(listTYPE);      // Returns a pointer to the matching element
  59.   int RmvData(listTYPE info);  // Remove the head of the list and free memory
  60.   void Clear();                // Empty the list
  61.   LListB *GetStart() { return Start; }
  62.   LListB *GetEnd() { return End; }
  63.   
  64. private:
  65.   LListB *Start;
  66.   LListB *End;
  67. };
  68.  
  69. #endif  // __LLIST_HPP__
  70. // ----------------------------------------------------------- // 
  71. // ------------------------------- //
  72. // --------- End of File --------- //
  73. // ------------------------------- //
  74.